<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>inweo.core.thread test</title>
		<script src="../lib/mootools.js"></script>
		<script src="../inweo.js"></script>
		<script type="text/javascript">
			function main() {
				inweo.require("box");
				inweo.require("label");
				inweo.require("thread", "utils");
				
				var page = new inweo.widgets.box(this);
				var label = new inweo.widgets.label();
				label.text("I am a dummy text");
				page.pack(label);

				var t1 = new inweo.utils.thread();
				var id = t1.start(function() {
					inweo.debug(this.data);
					this.data++;
				}, 1, 1000);
				t1.messageCallback(function(text, data) {
					if (text != "thread") {
						return;
					}
					inweo.debug(text);
				});

				new inweo.core.event(label).addEvent("keydown", function(event) {
					if (event.key == "r") {
						inweo.utils.threadManager.thread(id).resume();
					} else if (event.key == "p") {
						inweo.utils.threadManager.thread(id).pause();
					} else if (event.key == "s") {
						inweo.utils.threadManager.stopAll();
					} else if (event.key == "m") {
						inweo.message(inweo.utils.threadManager.thread(id), "thread", null);					}
				});
			}
		</script>
	</head>
	<body>
	</body>
</html>